/*
=======================================================================

  BOTS Kamikazee Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_KAMIKAZEE_SUICIDE		150
#define BOTS_KAMIKAZEE_DETMODE		151
#define BOTS_KAMIKAZEE_DETTRAP1		152
#define BOTS_KAMIKAZEE_DETTRAP2		153
#define BOTS_KAMIKAZEE_AUTOREWIRE	154
#define BOTS_KAMIKAZEE_LONGRANGE	155
#define BOTS_KAMIKAZEE_CLUSTER		156
#define BOTS_KAMIKAZEE_STICKMODE	157
#define BOTS_KAMIKAZEE_DETNUKE		158
#define BOTS_KAMIKAZEE_NORMAL		159

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	suicide;
  menutext_s	detmode;
  menutext_s	dettrap1;
  menutext_s	dettrap2;
  menutext_s	autorewire;
  menutext_s	longrange;
  menutext_s	cluster;
  menutext_s	stickmode;
  menutext_s	detnuke;
  menutext_s	normal;
  menutext_s	cancel;
} kamikazeeCommands_t;

static kamikazeeCommands_t		s_kamikazee;

/*
=================
BOTS_KamikazeeCommandsMenu_Event
callback routine
=================
*/
void BOTS_KamikazeeCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_KAMIKAZEE_SUICIDE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "suicide\n" );
		break;
	case BOTS_KAMIKAZEE_DETMODE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "detmode\n" );
		break;
	case BOTS_KAMIKAZEE_DETTRAP1:
		trap_Cmd_ExecuteText( EXEC_APPEND, "dettrap1\n" );
		break;
	case BOTS_KAMIKAZEE_DETTRAP2:
		trap_Cmd_ExecuteText( EXEC_APPEND, "dettrap2\n" );
		break;
	case BOTS_KAMIKAZEE_AUTOREWIRE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "autorewire\n" );
		break;
	case BOTS_KAMIKAZEE_LONGRANGE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "longrange\n" );
		break;
	case BOTS_KAMIKAZEE_CLUSTER:
		trap_Cmd_ExecuteText( EXEC_APPEND, "cluster\n" );
		break;
	case BOTS_KAMIKAZEE_STICKMODE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "stickmode\n" );
		break;
	case BOTS_KAMIKAZEE_DETNUKE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "detnuke\n" );
		break;

	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_KamikazeeCommandsMenu_Init
=================
*/
void BOTS_KamikazeeCommandsMenu_Init() 
{
	int y;

	memset( &s_kamikazee, 0 ,sizeof(kamikazeeCommands_t) );
	s_kamikazee.menu.wrapAround = qtrue;
	s_kamikazee.menu.fullscreen = qfalse;

	y = 96;
	s_kamikazee.title.generic.type	= MTYPE_PTEXT;
	s_kamikazee.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_kamikazee.title.generic.x		= 320;
	s_kamikazee.title.generic.y		= y;
	s_kamikazee.title.string		= "KAMIKAZEE COMMANDS MENU";
	s_kamikazee.title.color			= color_bots_menu;
	s_kamikazee.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.suicide.generic.type		= MTYPE_PTEXT;
	s_kamikazee.suicide.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.suicide.generic.x			= 320;
	s_kamikazee.suicide.generic.y			= y;
	s_kamikazee.suicide.generic.id			= BOTS_KAMIKAZEE_SUICIDE;
	s_kamikazee.suicide.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.suicide.string				= "COMMIT SUICIDE - suicide";
	s_kamikazee.suicide.color				= color_bots_menu;
	s_kamikazee.suicide.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.detmode.generic.type		= MTYPE_PTEXT;
	s_kamikazee.detmode.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.detmode.generic.x			= 320;
	s_kamikazee.detmode.generic.y			= y;
	s_kamikazee.detmode.generic.id			= BOTS_KAMIKAZEE_DETMODE;
	s_kamikazee.detmode.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.detmode.string				= "ACTIVATE DETPIPES - detmode";
	s_kamikazee.detmode.color				= color_bots_menu;
	s_kamikazee.detmode.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.dettrap1.generic.type		= MTYPE_PTEXT;
	s_kamikazee.dettrap1.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.dettrap1.generic.x			= 320;
	s_kamikazee.dettrap1.generic.y			= y;
	s_kamikazee.dettrap1.generic.id			= BOTS_KAMIKAZEE_DETTRAP1;
	s_kamikazee.dettrap1.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.dettrap1.string				= "DETONATE DETTRAP #1 - dettrap1";
	s_kamikazee.dettrap1.color				= color_bots_menu;
	s_kamikazee.dettrap1.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.dettrap2.generic.type		= MTYPE_PTEXT;
	s_kamikazee.dettrap2.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.dettrap2.generic.x			= 320;
	s_kamikazee.dettrap2.generic.y			= y;
	s_kamikazee.dettrap2.generic.id			= BOTS_KAMIKAZEE_DETTRAP2;
	s_kamikazee.dettrap2.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.dettrap2.string				= "DETONATE DETTRAP #2 - dettrap2";
	s_kamikazee.dettrap2.color				= color_bots_menu;
	s_kamikazee.dettrap2.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.autorewire.generic.type		= MTYPE_PTEXT;
	s_kamikazee.autorewire.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.autorewire.generic.x		= 320;
	s_kamikazee.autorewire.generic.y		= y;
	s_kamikazee.autorewire.generic.id		= BOTS_KAMIKAZEE_AUTOREWIRE;
	s_kamikazee.autorewire.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.autorewire.string			= "TOGGLE AUTOREWIRE - autorewire";
	s_kamikazee.autorewire.color			= color_bots_menu;
	s_kamikazee.autorewire.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.longrange.generic.type		= MTYPE_PTEXT;
	s_kamikazee.longrange.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.longrange.generic.x			= 320;
	s_kamikazee.longrange.generic.y			= y;
	s_kamikazee.longrange.generic.id		= BOTS_KAMIKAZEE_LONGRANGE;
	s_kamikazee.longrange.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.longrange.string			= "TOGGLE LONGRANGE GRENADES - longrange";
	s_kamikazee.longrange.color				= color_bots_menu;
	s_kamikazee.longrange.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 3) {
		s_kamikazee.longrange.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.cluster.generic.type		= MTYPE_PTEXT;
	s_kamikazee.cluster.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.cluster.generic.x			= 320;
	s_kamikazee.cluster.generic.y			= y;
	s_kamikazee.cluster.generic.id			= BOTS_KAMIKAZEE_CLUSTER;
	s_kamikazee.cluster.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.cluster.string				= "ACTIVATE CLUSTER GRENADES - cluster";
	s_kamikazee.cluster.color				= color_bots_menu;
	s_kamikazee.cluster.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 2) {
		s_kamikazee.cluster.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.normal.generic.type			= MTYPE_PTEXT;
	s_kamikazee.normal.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.normal.generic.x			= 320;
	s_kamikazee.normal.generic.y			= y;
	s_kamikazee.normal.generic.id			= BOTS_KAMIKAZEE_NORMAL;
	s_kamikazee.normal.generic.callback		= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.normal.string				= "ACTIVATE NORMAL GRENADES - normal";
	s_kamikazee.normal.color				= color_bots_menu;
	s_kamikazee.normal.style				= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.stickmode.generic.type		= MTYPE_PTEXT;
	s_kamikazee.stickmode.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.stickmode.generic.x			= 320;
	s_kamikazee.stickmode.generic.y			= y;
	s_kamikazee.stickmode.generic.id		= BOTS_KAMIKAZEE_STICKMODE;
	s_kamikazee.stickmode.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.stickmode.string			= "TOGGLE STICKY GRENADES - stickmode";
	s_kamikazee.stickmode.color				= color_bots_menu;
	s_kamikazee.stickmode.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 2) {
		s_kamikazee.stickmode.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.detnuke.generic.type		= MTYPE_PTEXT;
	s_kamikazee.detnuke.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.detnuke.generic.x			= 320;
	s_kamikazee.detnuke.generic.y			= y;
	s_kamikazee.detnuke.generic.id			= BOTS_KAMIKAZEE_DETNUKE;
	s_kamikazee.detnuke.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.detnuke.string				= "DETONATE NUKE - detnuke";
	s_kamikazee.detnuke.color				= color_bots_menu;
	s_kamikazee.detnuke.style				= UI_CENTER|UI_SMALLFONT;

	// grayed out for now...
	if (BOTS_GetClassLevel() < 5) {
		s_kamikazee.detnuke.generic.flags |= QMF_GRAYED;
	}

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_kamikazee.cancel.generic.type		= MTYPE_PTEXT;
	s_kamikazee.cancel.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_kamikazee.cancel.generic.x		= 320;
	s_kamikazee.cancel.generic.y		= y;
	s_kamikazee.cancel.generic.id		= BOTS_CANCEL;
	s_kamikazee.cancel.generic.callback	= BOTS_KamikazeeCommandsMenu_Event; 
	s_kamikazee.cancel.string			= "CANCEL";
	s_kamikazee.cancel.color			= color_bots_menu;
	s_kamikazee.cancel.style			= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.title );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.suicide );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.detmode );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.dettrap1 );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.dettrap2 );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.autorewire );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.longrange );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.cluster );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.normal );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.stickmode );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.detnuke );
	Menu_AddItem( &s_kamikazee.menu, &s_kamikazee.cancel );
}

void BOTS_KamikazeeCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_KamikazeeCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_kamikazee.menu );
}
